import java.util.Iterator;
import java.util.TreeMap;
import java.util.TreeSet;

class Student{

}
public class Test {
    public static void main(String[] args) {
        int[] array = {1,1,2,3,4,5,7,8,3,1,12,4,5,7,43,3,3,5};
        //找第一个重复的数据
        TreeSet<Integer> ser=new TreeSet<>();
        for(int i=0;i<array.length;i++){
            if(!ser.contains(array[i])){
                ser.add(array[i]);
            }else{
                System.out.print(array[i]+"");
                //别搞忘return
                return;
            }
        }





    }

    public static void main5(String[] args) {
        //去掉重复的数字
        int[] array = {1,1,2,3,4,5,7,8,3,1,12,4,5,7,43,3,3,5};
        TreeSet<Integer> set=new TreeSet<>();
        for(int i=0;i< array.length;i++){
            if(!set.contains(array[i])){
                set.add(array[i]);
            }
        }
        System.out.println(set);
    }
    public static void main4(String[] args) {
        TreeSet<String> set=new TreeSet<>();
        set.add("abcd");
        set.add("hello");
        set.add("maybe");
        Iterator<String> iterator=set.iterator();
        while(iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }

    }

    public static void main3(String[] args) {
        TreeMap<String,Integer> treeMap=new TreeMap<>();
        treeMap.put("abc",123);
        treeMap.put("h",123);
        treeMap.put("h",111);
        //Map中的key是唯一的，但value可重复
        System.out.println(treeMap);

    }












    public static void main2(String[] args) {
        TreeMap<Student,Integer> treeMap=new TreeMap<Student, Integer>();
        treeMap.put(new Student(),1);
        treeMap.put(new Student(),2);
        //TreeMap与TreeSet的key，必须能够比较

    }














    public static void main1(String[] args) {
        TreeMap<String,Integer> treeMap=new TreeMap<>();
        treeMap.put("abc",123);
        treeMap.put("hello",2);
        treeMap.put("w",51);
        treeMap.put("w",5);
        //Map类中的k是唯一的，不能重复，但value可重复，这里的value进行 更新了
        System.out.println(treeMap);

    }
}
